package com.wjc.${moudle}.controller.admin;




import com.wjc.${moudle}.BusinessApplication;
import com.wjc.server.dto.${Domain}Dto;
import com.wjc.server.dto.CommonDto;
import com.wjc.server.dto.PageDto;
import com.wjc.server.service.${Domain}Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;


@RestController
@RequestMapping("/admin/${domain}")
public class ${Domain}Controller {

    private static final Logger LOG= LoggerFactory.getLogger(BusinessApplication.class);
    public static final String BUSINESS_NAME = "${tableNameCn}";

    @Resource
    private ${Domain}Service ${domain}Service;

    //查询
    @GetMapping("/list")
    public CommonDto list(@Valid  PageDto pageDto){
         ${domain}Service.list(pageDto);
//         LOG.info("分页有啥: {}",pageDto);
        CommonDto<PageDto> pageDtoCommonDto = new CommonDto<>();
        pageDtoCommonDto.setContent(pageDto);
        return pageDtoCommonDto;
    }

    //保存
    @PostMapping("/save")
    public CommonDto list(@Valid @RequestBody ${Domain}Dto ${domain}Dto){
        CommonDto commonDto=new CommonDto<>();
        ${domain}Service.save(${domain}Dto);
        return commonDto;

    }

    //删除
    @DeleteMapping("/delete/{id}")
    public CommonDto delete(@PathVariable Long id){
        CommonDto commonDto=new CommonDto<>();
        ${domain}Service.delete(id);
        return commonDto;
    }
}
